package com.balabala.gym_goods.controller.app;

import com.balabala.goods.pojo.dto.LockStockDTO;
import com.balabala.gym_goods.service.SkuService;
import com.balabala.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author 何涛
 * @Date: 2023/05/08/ 13:28
 * @description 库存前台接口
 */
@RestController
@RequestMapping("/app/stock")
@Api(tags = "库存前台接口")
@Slf4j
@CrossOrigin
public class StockController {

    @Autowired
    SkuService skuService;
    @PutMapping("lock")
    @ApiOperation("批量锁定库存")
    public Result lockStocks(@RequestBody List<LockStockDTO> lockStockDTOS)
    {
        return skuService.batchLockStock(lockStockDTOS);
    }

    @PutMapping("unlock/{orderSn}")
    @ApiOperation("释放库存")
    public Result unlock(String orderSn){
        return Result.judge(skuService.unLockStock(orderSn));
    }
}
